---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Severity/PredictedValues.log
  log type:  text
 opened on:  12 Nov 2016, 21:49:19

. cd "/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Severity";
/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Severity

. **************************************************************;
. *Author: Jeff Carter                                         *;
. *Date: Saturday, May 23, 2015                              *;
. *Purpose: Simulating Predictions                *;
. **************************************************************;
. ** Need Legend for Probabilities and Differences  **;
. use "/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Severity/SimData.dta";

. postutil clear;

. postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 prob_hat2 lo2 hi2 prob_hat3 lo3 hi3 prob_hat4 lo4 hi4 prob_hat5 lo5 h
> i5
>                 diff_hat0 diff_lo0 diff_hi0 diff_hat1 diff_lo1 diff_hi1 diff_hat2 diff_lo2 diff_hi2 
>                 using PredictedValues, replace;
(note: file PredictedValues.dta not found)

. noisily display "start";
start

. local a=0 ;

. while `a' < .1 { ;
  2. {;
  3. scalar h_Accountable =   0  ;
  4. scalar h_LameDuck= 1  ;
  5. scalar h_Civilian = 0;
  6. scalar h_Military = 1;
  7. scalar h_Constant = 1;
  8. scalar h_Parliament = 0;
  9. scalar h_CivilWar = 0;
 10. scalar h_GDPpc =  12589.35;
 11. scalar h_Growth = 3.453132;
 12. scalar h_MajorPower = 0;
 13. scalar h_Borders = 2;
 14. scalar h_Mobilization =  -.0008714 ;
 15. scalar h_Time = 5;
 16.  scalar h_Rivalry = 0;
 17. scalar h_Female = 0;
 18. scalar h_Hawkish = 0;
 19. generate x_betahat0 = MG_b1*h_Accountable
>     + MG_b2*h_Hawkish
>     + MG_b3*h_Rivalry
>     + MG_b4*h_Borders
>     + MG_b5*h_Parliament
>     + MG_b6*h_Female 
>     + MG_b7*h_Time
>     + MG_b8*(h_Time^2)
>     + MG_b9*(h_Time^3);
 20. generate x_betahat1 = MG_b1* h_LameDuck
>     + MG_b2*h_Hawkish
>     + MG_b3*h_Rivalry
>     + MG_b4*h_Borders
>     + MG_b5*h_Parliament
>     + MG_b6*h_Female 
>     + MG_b7*h_Time
>     + MG_b8*(h_Time^2)
>     + MG_b9*(h_Time^3);
 21. gen prob0=  1/(1+exp(x_betahat0-MG_b10));
 22. gen prob1=   (1/(1+exp(x_betahat0-MG_b11)))  -  (1/(1+exp(x_betahat0-MG_b10)))  ;
 23. gen prob2=   1- (1/(1+exp(x_betahat0-MG_b11)));
 24. gen prob3=  1/(1+exp(x_betahat1-MG_b10));
 25. gen prob4=  (1/(1+exp(x_betahat1-MG_b11)))  -  (1/(1+exp(x_betahat1-MG_b10)))  ;
 26. gen prob5=   1- (1/(1+exp(x_betahat1-MG_b11)));
 27.         gen diff0=prob3-prob0 ;
 28. gen diff1=prob4-prob1 ;
 29. gen diff2=prob5-prob2 ;
 30.         egen probhat0=mean(prob0) ;
 31. egen probhat1=mean(prob1) ;
 32. egen probhat2=mean(prob2) ;
 33. egen probhat3=mean(prob3) ;
 34. egen probhat4=mean(prob4) ;
 35. egen probhat5=mean(prob5) ;
 36. egen diffhat0=mean(diff0) ;
 37. egen diffhat1=mean(diff1) ;
 38. egen diffhat2=mean(diff2) ;
 39. tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 prob_hat2 lo2 hi2 prob_hat3 lo3 hi3 prob_hat4 lo4 hi4 prob_hat5 lo5 hi5
>         diff_hat0 diff_lo0 diff_hi0 diff_hat1 diff_lo1 diff_hi1 diff_hat2 diff_lo2 diff_hi2;
 40.             _pctile prob0, p(2.5,97.5) ;
 41.     scalar `lo0'=r(r1) ;
 42.     scalar `hi0'=r(r2) ;
 43.     _pctile prob1, p(2.5,97.5) ;
 44.     scalar `lo1'=r(r1) ;
 45.     scalar `hi1'=r(r2) ;
 46.     _pctile prob2, p(2.5,97.5) ;
 47.     scalar `lo2'=r(r1) ;
 48.     scalar `hi2'=r(r2) ;
 49.     _pctile prob3, p(2.5,97.5) ;
 50.     scalar `lo3'=r(r1) ;
 51.     scalar `hi3'=r(r2) ;
 52.     _pctile prob4, p(2.5,97.5) ;
 53.     scalar `lo4'=r(r1) ;
 54.     scalar `hi4'=r(r2) ;
 55.     _pctile prob5, p(2.5,97.5) ;
 56.     scalar `lo5'=r(r1) ;
 57.     scalar `hi5'=r(r2) ;
 58.             _pctile diff0, p(2.5,97.5) ;
 59.     scalar `diff_lo0'= r(r1) ;
 60.     scalar `diff_hi0'=r(r2) ;
 61.     _pctile diff1, p(2.5,97.5) ;
 62.     scalar `diff_lo1'= r(r1) ;
 63.     scalar `diff_hi1'=r(r2) ;
 64.     _pctile diff2, p(2.5,97.5) ;
 65.     scalar `diff_lo2'= r(r1) ;
 66.     scalar `diff_hi2'=r(r2) ;
 67.             scalar `prob_hat0'=probhat0 ;
 68.     scalar `prob_hat1'=probhat1 ;
 69.     scalar `prob_hat2'=probhat2 ;
 70.     scalar `prob_hat3'=probhat3 ;
 71.     scalar `prob_hat4'=probhat4 ;
 72.     scalar `prob_hat5'=probhat5 ;
 73.           scalar `diff_hat0'=diffhat0 ;
 74.     scalar `diff_hat1'=diffhat1 ;
 75.     scalar `diff_hat2'=diffhat2 ;
 76.  post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`prob_hat2') (`lo2') (`hi2')
>         (`prob_hat3') (`lo3') (`hi3') (`prob_hat4') (`lo4') (`hi4') (`prob_hat5') (`lo5') (`hi5')
>         (`diff_hat0') (`diff_lo0') (`diff_hi0') (`diff_hat1') (`diff_lo1') (`diff_hi1') (`diff_hat2') (`diff_lo2') (`diff
> _hi2')
> 
> 
>     ;
 77.     } ;
 78. drop    x_betahat0 x_betahat1
>         prob0 prob1 prob2 prob3 prob4 prob5
>         diff0 diff1 diff2
>         probhat0 probhat1 probhat2 probhat3 probhat4 probhat5
>         diffhat0 diffhat1 diffhat2;
 79.     local a=`a'+ .1 ;
 80.     display "." _c ;
 81.     } ;
.
. display "" ;


.  postclose mypost ;

. use PredictedValues, clear;

. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   prob_hat0 |         1    .9556456           .   .9556456   .9556456
         lo0 |         1    .9358764           .   .9358764   .9358764
         hi0 |         1    .9705697           .   .9705697   .9705697
   prob_hat1 |         1    .0343448           .   .0343448   .0343448
         lo1 |         1    .0226729           .   .0226729   .0226729
-------------+--------------------------------------------------------
         hi1 |         1    .0497612           .   .0497612   .0497612
   prob_hat2 |         1    .0100096           .   .0100096   .0100096
         lo2 |         1    .0063204           .   .0063204   .0063204
         hi2 |         1    .0151499           .   .0151499   .0151499
   prob_hat3 |         1    .9757516           .   .9757516   .9757516
-------------+--------------------------------------------------------
         lo3 |         1     .962998           .    .962998    .962998
         hi3 |         1    .9850581           .   .9850581   .9850581
   prob_hat4 |         1    .0188628           .   .0188628   .0188628
         lo4 |         1    .0115323           .   .0115323   .0115323
         hi4 |         1    .0289446           .   .0289446   .0289446
-------------+--------------------------------------------------------
   prob_hat5 |         1    .0053856           .   .0053856   .0053856
         lo5 |         1    .0031821           .   .0031821   .0031821
         hi5 |         1    .0085769           .   .0085769   .0085769
   diff_hat0 |         1    .0201061           .   .0201061   .0201061
    diff_lo0 |         1    .0057452           .   .0057452   .0057452
-------------+--------------------------------------------------------
    diff_hi0 |         1    .0370578           .   .0370578   .0370578
   diff_hat1 |         1   -.0154821           .  -.0154821  -.0154821
    diff_lo1 |         1   -.0286782           .  -.0286782  -.0286782
    diff_hi1 |         1   -.0044294           .  -.0044294  -.0044294
   diff_hat2 |         1    -.004624           .   -.004624   -.004624
-------------+--------------------------------------------------------
    diff_lo2 |         1   -.0087867           .  -.0087867  -.0087867
    diff_hi2 |         1   -.0013308           .  -.0013308  -.0013308

. saveold PredictedValues, replace;
file PredictedValues.dta saved

. log close;
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Severity/PredictedValues.log
  log type:  text
 closed on:  12 Nov 2016, 21:49:19
---------------------------------------------------------------------------------------------------------------------------
